<template>
  <view>
    <div class="wrapper">
      <view class="tit"
        :style="{
          
          'color':color
        }"
      >
        <view class="l">{{val}}</view>
        <view class="r">%</view>
      </view>
<!-- 'bottom':titBottom, -->
    <div class="charger">
    <div class="box">
      <!-- <view class="tit"
        :style="{
          
          'color':color
        }"
      >
        <view class="l">{{val}}</view>
        <view class="r">%</view>
      </view> -->
      <div class="wave wave-one" :style="{
        'bottom':waveBottom,
        'background':bg
      }"></div>
      <div class="wave wave-two" :style="{
        'bottom':waveBottom,
        'background':bg
      }"></div>
      <div class="wave wave-three" :style="{
        'bottom':waveBottom,
        'background':bg
      }"></div>
      <div class="shade"></div>
      <div class='title'>charging...</div>
    </div>
    </div>
    </div>
  </view>
</template>

<script>
  export default{
    props:{
      'num':{
        type:Number,
        default:20
      }
    },
    data(){
      return{
        waveBottom:'50%', // 20 - 76  ， 50 - 53 ， 80 - 35
        bg:'linear-gradient( 180deg, #FFFCC7 0%, #F4C164 100%)', // 50
        val:50,
        titBottom:'38%', // 20 - 38 ， 50 - 19， 80 - 2
        color:'', // 20 - rgba(239, 120, 48, 1)， 50 - rgba(231, 176, 32, 1) ， 80 - rgba(13, 172, 113, 1)
      }
    },
    watch:{
      num:{
        handler(value){
          this.val = value
          if(value<50){
            this.waveBottom = '76%'
            this.bg = 'linear-gradient( 180deg, #FFD1AE 0%, #FF8650 100%)'
            this.titBottom = '38%'
            this.color = 'rgba(239, 120, 48, 1)'
          }else if(value<80){
            this.waveBottom = '53%'
            this.bg = 'linear-gradient( 180deg, #FFFCC7 0%, #F4C164 100%)'
            this.titBottom = '19%'
            this.color = 'rgba(231, 176, 32, 1)'
          }else{
            this.waveBottom = '35%'
            this.bg = 'linear-gradient( 180deg, #C7FFE5 0%, #48D5A9 100%)'
            this.titBottom = '2%'
            this.color = 'rgba(13, 172, 113, 1)'
          }
        },
        immediate:true
      }
    }
  }
</script>

<style lang="scss" scoped>
  // @import url('https://fonts.googleapis.com/css2?family=Goldman&display=swap');
  
  html, body {
    height: 100%;
  }
  
  body {
    background: radial-gradient(circle, rgba(21,21,23,1) 26%, rgba(6,6,6,1) 63%);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .wrapper {
    // width: 1000px;
    position: relative;
    display: flex;
    // justify-content: center;
    align-items: center;
    
    
    .tit{
        position: absolute;
        // bottom: 124rpx;
        top: 29%;

        left: 0;
        right: 0;
        
        display: flex;
        justify-content: center;
        // transform: scale(-1, -1) translateY(-50%);
        color: #EF7830;
        
            -webkit-text-stroke: 4rpx #FFFFFF;

    
        z-index: 2;
        
        .l{
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          font-size: 100rpx;
          
          line-height: 112rpx;
          text-align: right;
          font-style: normal;
          
          
        }
        
        .r{
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          font-size: 70rpx;
          
          line-height: 130rpx;
          text-align: left;
          font-style: normal;
          margin-left: 3rpx;
        }
      }
    
  }
  

  .charger {
    position: relative;
    top: 0;
    left: 0;
    width: 400rpx;
    height: 400rpx;
    // border: 2px solid #d7d2cc;
    // background: black;
    background: linear-gradient( 167deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.1) 34%, rgba(255,255,255,0.63) 69%, #FFFFFF 100%);
    
    border-radius: 100%;
        overflow: hidden;

    transform: scale(.59);
    

  }
  
  .box {
    // left: 10px;
    width: 400rpx;
    height: 400rpx;
    // background: black;
    border-radius: 25px;
    position: relative;
    overflow: hidden;
    transform: rotate(180deg);
    
    .tit{
      position: absolute;
      // bottom: 124rpx;
      bottom: 30%;
      left: 0;
      right: 0;
      
      display: flex;
      justify-content: center;
      transform: scale(-1, -1) translateY(-50%);
      color: #EF7830;

      z-index: 2;
      
      .l{
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 100rpx;
        
        line-height: 112rpx;
        text-align: right;
        font-style: normal;
      }
      
      .r{
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 70rpx;
        
        line-height: 130rpx;
        text-align: left;
        font-style: normal;
        margin-left: 3rpx;
      }
    }
  }
  
  .wave {
    opacity: 0.7;
    position: absolute;
    bottom: 60%;
    left: 50%;
    // background: linear-gradient(to right, #ff00cc, #333399);
    background: linear-gradient( 180deg, #FFD1AE 0%, #FF8650 100%);
    width: 500px;
    height: 500px;
    transform-origin: 50% 48%;
    border-radius: 40%;
    margin-left: -250px;
    margin-top: -250px;
    animation: 5000ms linear infinite reverse drift;
  }
  
  .wave-three {
    animation: 5000ms linear infinite drift;
    
    opacity: 0.7;
  }
  
  .wave .wave-two {
    animation: 7000ms linear infinite backwards drift;
    opacity: .6;
  }
  
  .shade {
    width: 25px;
    height: 70px;
    // background: #fc67fa;
    border-radius: 25px;
    position: relative;
    left: 85%;
    top: 10%;
  }
  
  .x1 {
  	animation: animateBubble 10s linear infinite, sideWays 2s ease-in-out infinite alternate;
  	left: -5%;
  	top: 5%;
  	transform: scale(0.1);
  }
  .x2 {
  	animation: animateBubble 15s linear infinite, sideWays 5s ease-in-out infinite alternate;
  	left: 5%;
  	top: 4%;
  	transform: scale(0.09);
  }
  .x3 {
  	animation: animateBubble 12s linear infinite, sideWays 2s ease-in-out infinite alternate;
  	left: 5%;
  	top: 10%;
  	transform: scale(0.09);
  }
  .x4 {
  	animation: animateBubble 16s linear infinite, sideWays 3s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;
  	transform: scale(0.09);
  }
  .x5 {
  	animation: animateBubble 14s linear infinite, sideWays 6s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;
  	transform: scale(0.09);
  }
  .x6 {
  	animation: animateBubble 17s linear infinite, sideWays 3s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;
  	transform: scale(0.09);
  }
  .x7 {
  	animation: animateBubble 16s linear infinite, sideWays 5s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;;
  	transform: scale(0.09);
  }
  .x8 {
  	animation: animateBubble 19s linear infinite, sideWays 2s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;;
  	transform: scale(0.09);
  }
  .x9 {
  	animation: animateBubble 18s linear infinite, sideWays 4s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;;
  	transform: scale(0.09);
  }
  .x10 {
  	animation: animateBubble 20s linear infinite, sideWays 5s ease-in-out infinite alternate;
  	left: 5%;
  	top: 8%;;
  	transform: scale(0.09);
  }
  .bubble {
  	border-radius: 50%;
    height: 200px;
  	position: absolute;
  	width: 200px;
  }
  
  .bubble:after {
     background: linear-gradient( #ff00cc, #333399);
  	border-radius: 50%;
  	content: "";
    height: 180px;
  	left: 10px;
  	position: absolute;
  	width: 180px;
  }
  
  .title {
    position: absolute;
    right: 7%;
    bottom: 40%;
    transform: rotate(180deg);
    width: 100%;
    line-height: 300px;
    text-align: center;
    color: white;
    font-family: 'Goldman', cursive;
    letter-spacing: .2em;
    font-size: 20px;
    text-shadow: 0 1px 0 rgba(black, .1);
    text-indent: .3em;
  }
  
  @keyframes drift {
    from {transform: rotate(0deg);}
    from {transform: rotate(360deg);}
  }
  @keyframes animateBubble {
      0% {
          margin-top: 10px;
      }
      100% {
          margin-top: 900%;
      }
  }
  @keyframes sideWays { 
      0% { 
          margin-left:0px;
      }
      100% { 
          margin-left:50px;
      }
  }
</style>